﻿<%@ Page Language="C#" MasterPageFile="~/WebSite/manager.Master" AutoEventWireup="true" CodeFile="m_data_otherLevel.aspx.cs" Inherits="WebSite_m_data_otherLevel" Title="无标题页" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <style type="text/css">
        .InfoStyle
        {
        	margin:25px;
        	margin-left:0px;
        	width:640px;
        	overflow:visible;
       	}
       	.InfoStyle h1
       	{
       		font-size:20px;
       		background-image:url(../images/Clip.png);
       		background-repeat:no-repeat;
       		width:300px;
       		margin:-23px auto auto 180px;
       		padding-top:15px;
       		padding-left:50px;
       		height:40px;
       	}
       	.InsertBtnStyle
       	{
       		margin:5px 200px auto;
    	    width:90px;
    	    height:30px;
    	    background-color:#669DF0;
    	    font-size:16px;
    	    font-weight:bold;
    	    color:#FFFFFF;
       	}
       	.TableStyle
       	{
       		margin:0px 50px;
       	}
    </style>
    
<div class="InfoStyle">
        <h1>其他项目信息表</h1>
        <br />
        <div class="TableStyle">
        <asp:GridView ID="UserDetailGridView" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False"  DataKeyNames="TestName,LowerLimit,UpLimit,Sex"
            DataSourceID="SqlDataSource1" CellPadding="4" Font-Size="15px" 
                                        PageSize="20" ForeColor="#333333" GridLines="None">
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="TestName" HeaderText="测试名称" SortExpression="TestName" ItemStyle-Width="120px" ControlStyle-Width="100px">
                </asp:BoundField>
                <asp:BoundField DataField="LowerLimit" HeaderText="下限" 
                    SortExpression="LowerLimit" DataFormatString="{0:F}" ControlStyle-Width="50px">
                </asp:BoundField>
                <asp:BoundField DataField="UpLimit" HeaderText="上限" SortExpression="UpLimit"  DataFormatString="{0:F}" ControlStyle-Width="50px">
                </asp:BoundField>
                <asp:TemplateField HeaderText="性别" SortExpression="Sex">
                    <ItemTemplate>
                        <asp:DropDownList runat="server" ID="SexDropDownList" 
                            SelectedValue='<%# Bind("Sex", "{0}") %>'>
                            <asp:ListItem Value="False">男</asp:ListItem>
                            <asp:ListItem Value="True">女</asp:ListItem>
                        </asp:DropDownList>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Mark" HeaderText="分数" SortExpression="Mark"  ControlStyle-Width="40px">
                </asp:BoundField>
                <asp:BoundField DataField="Level" HeaderText="等级"  SortExpression="Level"  ControlStyle-Width="80px">
                </asp:BoundField>
                <asp:BoundField DataField="HeavyWeight" HeaderText="权重" 
                    SortExpression="HeavyWeight"  ControlStyle-Width="50px">
                </asp:BoundField>
            </Columns>
            <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#2461BF" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <br />
        <table style="font-size:15px; text-align:center; margin-left:0px;">
            <tr>
                <td>测试名称</td>
                <td>下限</td>
                <td>上限</td>
                <td>性别</td>
                <td>分数</td>
                <td>等级</td>
                <td>权重</td>
            </tr>
            <tr>
                <td>
                    <asp:DropDownList ID="TestNameDropDownList" runat="server" style="width:90px;" 
                        DataSourceID="SqlDataSource2" DataTextField="TestName" 
                        DataValueField="TestName">
                    </asp:DropDownList>
                </td>
                <td>
                    <asp:TextBox ID="LowTextBox" runat="server" EnableViewState="False" Wrap="False" Width="59px"/>
                </td>
                <td>
                    <asp:TextBox ID="HighTextBox" runat="server" EnableViewState="False" Wrap="False" Width="59px"/>
                </td>
                <td>
                    <asp:DropDownList ID="SexDropDownList" runat="server">
                        <asp:ListItem Value="0">男</asp:ListItem>
                        <asp:ListItem Value="1">女</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td>
                    <asp:TextBox ID="MarkTextBox" runat="server" style="width:50px" Height="19px" 
                        Width="83px" />
                </td>
                <td>
                    <asp:TextBox ID="LevelTextBox" runat="server" style="width:70px" MaxLength="5"/>
                </td>
                <td>
                    <asp:TextBox ID="HeavyWeightTextBox" runat="server" Width="40px" />
                </td>
           </tr>
        </table>
        <asp:Button ID="InsertBtn" runat="server" Text="插入信息" OnClick="InsertBtn_Click" 
                CssClass="InsertBtnStyle"/>
    </div>
        
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
            ControlToValidate="HighTextBox" Display="Dynamic" ErrorMessage="上限必须为浮点数" 
            ValidationExpression="^[+]?\d*\.?\d*$"></asp:RegularExpressionValidator>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
            ControlToValidate="LowTextBox" Display="Dynamic" ErrorMessage="下限必须为浮点数" 
            ValidationExpression="^[+]?\d*\.?\d*$"></asp:RegularExpressionValidator>
        <asp:CompareValidator ID="CompareValidator1" runat="server" 
            ControlToCompare="LowTextBox" ControlToValidate="HighTextBox" 
            ErrorMessage="上限要大于下限" Operator="GreaterThan" Display="Dynamic"></asp:CompareValidator>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
            ControlToValidate="MarkTextBox" Display="Dynamic" ErrorMessage="分数为0-100间正整数" 
            ValidationExpression="^(0|[1-9]?[0-9])$|100"></asp:RegularExpressionValidator>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" 
            ControlToValidate="HeavyWeightTextBox" Display="Dynamic" ErrorMessage="权重为0-100间正整数" 
            ValidationExpression="^(0|[1-9]?[0-9])$|100"></asp:RegularExpressionValidator>
     
            
  <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
            
        SelectCommand="SELECT [TestName], [LowerLimit], [UpLimit], [Sex], [Mark], [Level], [HeavyWeight] FROM [TargetLevel]" 
        DeleteCommand="DELETE FROM [TargetLevel] WHERE [TestName] = @original_TestName AND [LowerLimit] = @original_LowerLimit AND [UpLimit] = @original_UpLimit AND [Sex] = @original_Sex"  
        
        UpdateCommand="UPDATE [TargetLevel] SET [Mark] = @Mark, [Level] = @Level, [HeavyWeight] = @HeavyWeight WHERE [TestName] = @original_TestName AND [LowerLimit] = @original_LowerLimit AND [UpLimit] = @original_UpLimit AND [Sex] = @original_Sex" 
        InsertCommand="INSERT INTO [TargetLevel] ([TestName], [LowerLimit], [UpLimit], [Sex], [Mark], [Level], [HeavyWeight]) VALUES (@TestName, @LowerLimit, @UpLimit, @Sex, @Mark, @Level, @HeavyWeight)" 
        OldValuesParameterFormatString="original_{0}" >
            <DeleteParameters>
                <asp:Parameter Name="original_TestName" Type="String" />
                <asp:Parameter Name="original_LowerLimit" Type="Double" />
                <asp:Parameter Name="original_UpLimit" Type="Double" />
                <asp:Parameter Name="original_Sex" Type="Boolean" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Mark" Type="Int32" />
                <asp:Parameter Name="Level" Type="String" />
                <asp:Parameter Name="HeavyWeight" Type="Double" />
                <asp:Parameter Name="original_TestName" Type="String" />
                <asp:Parameter Name="original_LowerLimit" Type="Double" />
                <asp:Parameter Name="original_UpLimit" Type="Double" />
                <asp:Parameter Name="original_Sex" Type="Boolean" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="TestName" Type="String" />
                <asp:Parameter Name="LowerLimit" Type="Double" />
                <asp:Parameter Name="UpLimit" Type="Double" />
                <asp:Parameter Name="Sex" Type="Boolean" />
                <asp:Parameter Name="Mark" Type="Int32" />
                <asp:Parameter Name="Level" Type="String" />
                <asp:Parameter Name="HeavyWeight" Type="Double" />
            </InsertParameters>
        </asp:SqlDataSource>
        
        
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:CSHDBConnectionString %>" 
            SelectCommand="SELECT LTRIM(RTRIM(TestName)) AS TestName FROM TargetCatagory WHERE (ItemCatagory &lt;&gt; '奖惩项目') AND CHARINDEX('米',TestName)=0">
        </asp:SqlDataSource>
        
        
</div>

    <asp:Label ID="WarnLabel" runat="server" ForeColor="Red" Visible="false" /> 
</asp:Content>

